<?php 
	defined('IN_PHPCMS') or exit('NO permission resoures.');
	class yubao {
		function __construct(){	
			$this->username=param::get_cookie('_username');
			if($this->username!=null){
				//echo 'loading db';
				$this->yubao_db=pc_base::load_model('yubao_model');
				//echo 'loaded db';			
			}else{
				exit('here');
				showmessage('请登录后尝试此操作','index.php');
			}				
		}
		
		function init(){
			include template('order','yubao');
		}
		function add(){
			print_r($_POST);
			//exit();
			if(isset($_POST['dosubmit'])){
				$yborder=Array();
				$yborder['username']=$this->username;
				$yborder['warehouse']=isset($_POST['warehouse'])?safe_replace($_POST['warehouse']):exit('0');
				$yborder['zhcompany']=isset($_POST['zhcompany'])?safe_replace($_POST['zhcompany']):exit('0');
				$yborder['amount']=isset($_POST['amount'])?safe_replace($_POST['amount']):'未填写货物件数';
				$yborder['zhnumber']=isset($_POST['zhnumber'])?safe_replace($_POST['zhnumber']):exit('请填转运号码');
				$yborder['pack']=isset($_POST['pack'])?safe_replace($_POST['pack']):exit('0');
				$yborder['remark']=isset($_POST['remark'])?safe_replace($_POST['remark']):"未填写";
				$yborder['whprice']=isset($_POST['whprice'])?safe_replace($_POST['whprice']):exit('请填写保价单');
				$this->yubao_db->insert( $yborder );
				showmessage('提交预报单成功');
			}else{
				exit('请通过正常途径提交');
			}
		}
	}	